home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / src / mta / mta.sos < prev   
Encoding:
Text File  |  1991-11-08  |  8.2 KB  |  294 lines

  1. /* --------------------------------------------------------------------------
  2.  * Copyright 1992 by Forschungszentrum Informatik (FZI)
  3.  *
  4.  * You can use and distribute this software under the terms of the licence
  5.  * you should have received along with this program.
  6.  * If not or if you want additional information, write to
  7.  * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  8.  * D-7500 Karlsruhe 1, Germany.
  9.  * --------------------------------------------------------------------------
  10.  */
  11. /* ******************************************************************** */
  12. /*                          SOS meta schema                             */
  13. /* ******************************************************************** */
  14.  
  15. with agg, dir;
  16.  
  17. schema mta
  18. {
  19.  
  20. typedef Mapping <sos_String, sos_Schema_type> sos_Type_table;
  21.  
  22. class sos_Imports : List <sos_Schema_module> (FALSE)
  23. {
  24. public:
  25.    sos_Schema_type lookup_type (sos_String name,
  26.                                 sos_Bool   look_for_alias = FALSE);
  27. };
  28.  
  29. class sos_Schema_impl {};
  30.  
  31. class sos_Method_impl {};
  32.  
  33. class sos_Expr {};
  34.  
  35. class sos_Schema_module : sos_Named
  36. {
  37. public:
  38.    static Directory<sos_Schema_module>  schema_dir ();
  39.    static sos_Schema_module             lookup (sos_String);
  40.    static sos_Schema_module             retrieve (sos_Container);
  41.  
  42.    local  sos_String                    name;
  43.    local  sos_Imports                   imports;
  44.    local  List <sos_Schema_type>        types;
  45.    local  sos_Type_table                type_table;
  46.           sos_Bool                      has_external_import;
  47.           sos_Bool                      has_external_types;
  48.    local  List <sos_Schema_impl>        impls;
  49.  
  50.    sos_Schema_type  lookup_type (sos_String name,
  51.                                  sos_Bool   look_for_alias = FALSE);
  52.    void             open_imports ();
  53.    void             close_imports ();
  54.    void             install ();
  55. };
  56.  
  57. class sos_Int_expr : sos_Expr
  58. {
  59. public:
  60.    sos_Int    value;
  61. };
  62.  
  63. class sos_Identifier : sos_Expr
  64. {
  65. public:
  66.    sos_String id;
  67. };
  68.  
  69. class sos_Type_name
  70. {
  71. public:
  72.    sos_Schema_type      make_root_type ();
  73.    sos_Schema_type      make_base_type ();
  74.    List <sos_Expr>      create_params ();
  75.  
  76.    abstract sos_Schema_type     make_type ();
  77.    abstract sos_String          make_type_name ();
  78. };
  79.  
  80. class sos_Schema_type : sos_Type, sos_Type_name
  81. {
  82. public:
  83.    sos_Bool     is_derived_from (sos_Type);      // -> sos_Type
  84.    sos_Bool     is_derived_from_some (sos_Type); // -> sos_Type
  85.    sos_Bool     is_scalar ();                    // -> sos_Type
  86.    sos_Type     base ();                         // -> sos_Type
  87.  
  88.    sos_Schema_type      make_type ();            // -> sos_Type_name
  89.    sos_String           make_type_name ();       // -> sos_Type_name
  90.  
  91. protected:
  92.    static sos_Bool total_equal (sos_Schema_type,
  93.                                 sos_Object, sos_Eq_kind);
  94.    static sos_Int  total_hash_value (sos_Schema_type);
  95. };
  96.  
  97. class sos_Unidentified_type : sos_Type_name, sos_Named
  98. {
  99. public:
  100.    local sos_String     name;
  101.  
  102.    sos_Schema_type      make_type ();            // -> sos_Type_name
  103.    sos_String           make_type_name ();       // -> sos_Type_name
  104. };
  105.  
  106. class sos_Type_with_params : sos_Type_name
  107. {
  108. public:
  109.    sos_Type_name        type_name;
  110.    List <sos_Expr>      params;
  111.  
  112.    List <sos_Expr>      create_params ();        // -> sos_Type_name
  113.    sos_Schema_type      make_type ();            // -> sos_Type_name
  114.    sos_String           make_type_name ();       // -> sos_Type_name
  115. };
  116.  
  117. class sos_Generic_instantiation : sos_Type_name
  118. {
  119. public:
  120.           sos_Class_type        gen;
  121.    local  List <sos_Type_name>  gen_params;
  122.           sos_Class_type        instantiation;
  123.  
  124.    sos_Bool             is_universal ();
  125.  
  126.    sos_Schema_type      make_type ();            // -> sos_Type_name
  127.    sos_String           make_type_name ();       // -> sos_Type_name
  128. };
  129.  
  130. class sos_Gen_param : sos_Type_name, sos_Named
  131. {
  132. public:
  133.          sos_String     name;
  134.          sos_Type_name  super_class;
  135.  
  136.    sos_Schema_type      make_type ();            // -> sos_Type_name
  137.    sos_String           make_type_name ();       // -> sos_Type_name
  138. };
  139.  
  140. class sos_Param : sos_Named
  141. {
  142. public:
  143.          sos_String     name;
  144.          sos_Type_name  type_name;
  145.          sos_Bool       is_ref;
  146.          sos_Expr       default_expr;
  147. };
  148.  
  149. enum sos_Method_kind
  150. {  sos_PRIVATE,
  151.    sos_PROTECTED,
  152.    sos_PUBLIC
  153. };
  154.  
  155. class sos_Method : sos_Named
  156. {
  157. public:
  158.          sos_String             name;
  159.          sos_Method_kind        kind;
  160.      sos_Bool        is_abstract;
  161.          sos_Bool               is_static;
  162.          sos_Bool               is_operator;
  163.          sos_Bool               is_predefined;
  164.          sos_Method             generated_from;
  165.    local sos_Class_type         defined_in;
  166.          List <sos_Param>       params;
  167.          sos_Type_name          result_type;
  168.    local List <sos_Method_impl> impls;
  169.  
  170.    sos_Bool     overloads (sos_Method);
  171.    sos_Bool     redefines (sos_Method);
  172.    sos_Object   execute (sos_Object, Array <sos_Object>);
  173. };
  174.  
  175. class sos_Method_table
  176.       : Mapping <sos_String, List <sos_Method>> (FALSE, TRUE, FALSE)
  177. {
  178. public:
  179.    sos_Method           lookup (sos_Method);
  180.    sos_Method           lookup_or_add (sos_Method);
  181.    sos_Method           replace_or_add (sos_Method);
  182.  
  183.    sos_Comp_method      lookup_comp (sos_String, sos_Bool is_set);
  184. };
  185.  
  186. class sos_Comp_method : sos_Method
  187. {
  188. public:
  189.    sos_Expr       init_expr;
  190.    sos_Bool       is_set;
  191.    sos_Bool       is_value;
  192.    sos_Bool       is_local;
  193.    sos_Int        offset;
  194. };
  195.  
  196. class sos_Union_type : sos_Schema_type 
  197. {
  198. public:
  199.    local  List <sos_Type_name> uniteds;
  200.  
  201. protected:
  202.    static sos_Bool local_equal (sos_Union_type,
  203.                                 sos_Object, sos_Eq_kind);
  204.    static sos_Int  local_hash_value (sos_Union_type);
  205. };
  206.  
  207. class sos_Typedef_type : sos_Schema_type 
  208. {
  209. public:
  210.    sos_Type_name        type_name;
  211.  
  212.    sos_Schema_type      make_base_type ();       // -> sos_Type_name
  213.  
  214. protected:
  215.    static sos_Bool local_equal (sos_Typedef_type,
  216.                                 sos_Object, sos_Eq_kind);
  217.    static sos_Int  local_hash_value (sos_Typedef_type);
  218. };
  219.  
  220. class sos_Enum_type : sos_Schema_type 
  221. {
  222. public:
  223.    local  List <sos_String>     literals;
  224.  
  225.           sos_Scalar_object     make_object (sos_String);
  226.           sos_String            make_string (sos_Scalar_object);
  227.  
  228. protected:
  229.    static sos_Bool local_equal (sos_Enum_type,
  230.                                 sos_Object, sos_Eq_kind);
  231.    static sos_Int  local_hash_value (sos_Enum_type);
  232. };
  233.  
  234. class sos_Extern_type : sos_Schema_type 
  235. {
  236. };
  237.  
  238. class sos_Forward_class_type : sos_Schema_type 
  239. {
  240. public:
  241.    sos_Class_type       complete;
  242.  
  243.    sos_Schema_type      make_base_type ();       // -> sos_Type_name
  244.  
  245. protected:
  246.    static sos_Bool local_equal (sos_Forward_class_type,
  247.                                 sos_Object, sos_Eq_kind);
  248.    static sos_Int  local_hash_value (sos_Forward_class_type);
  249. };
  250.  
  251. class sos_Super_class
  252. {
  253. public:
  254.    sos_Class_type  super_class;
  255.    List <sos_Expr> create_params;
  256.    sos_Int         offset;
  257. };
  258.  
  259. class sos_Class_type  : sos_Schema_type 
  260. {
  261. public:
  262.           List <sos_Gen_param>          gen_params;
  263.           List <sos_Param>              create_params;
  264.           sos_Bool                      has_init_comps;
  265.       sos_Bool            is_abstract;
  266.           List <sos_Type_name>          friends;
  267.           List <sos_Type_name>          super_classes;
  268.    local  List <sos_Super_class>        super_closure;
  269.           List <sos_Method>             methods;
  270.           List <sos_Method>             comp_methods;
  271.           List <sos_Method>             static_methods;
  272.    local  sos_Method_table              inherited_methods;
  273.  
  274.           sos_Generic_instantiation     generated_from;
  275.    local  sos_String                    root_name;
  276.  
  277.           sos_Int                       local_size;
  278.  
  279.    sos_Class_type    root_class ();
  280.  
  281.    sos_Bool         is_derived_from (sos_Type);      // -> sos_Type
  282.    sos_Bool         is_derived_from_some (sos_Type); // -> sos_Type
  283.    sos_Type         root ();                         // -> sos_Type
  284.    sos_Schema_type  make_root_type ();               // -> sos_Type_name
  285.    sos_String       make_type_name ();               // -> sos_Type_name
  286.  
  287. protected:
  288.    static sos_Bool local_equal (sos_Class_type,
  289.                                 sos_Object, sos_Eq_kind);
  290.    static sos_Int  local_hash_value (sos_Class_type);
  291. };
  292.  
  293. } // ** schema mta **
  294.